package start.spring.basic.job.quartz;

import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;

/**
 * ****************************************************************************
 * 任务工厂类
 *
 * @author(作者)：xuyongyun	
 * @date(创建日期)：2018年8月30日
 ******************************************************************************
 */
@Component
public class SpringJobFactory extends AdaptableJobFactory {
	
	@Autowired
	private AutowireCapableBeanFactory capableBeanFactory;
	 
	@Override
	protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
	    Object jobInstance = super.createJobInstance(bundle);
	    capableBeanFactory.autowireBean(jobInstance);
	    return jobInstance;
	}
}
